# Contributor: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
# Maintainer: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
pkgname=coccinelle
pkgver=1.0.8
pkgrel=1
pkgdesc="SmPL (Semantic Patch Language) implementation"
url="http://coccinelle.lip6.fr/"
# x86, armhf, s390x, mips, mips64: limited by ocaml aport
arch="all !x86 !armhf !armv7 !s390x !mips !mips64"
license="GPL-2.0-only"
subpackages="$pkgname-doc"
makedepends="
	autoconf
	automake
	ocaml-dev
	ocaml-findlib-dev
	ocaml-num-dev
	ocaml-ocamldoc
	pcre-dev
	"
depends="python3"
subpackages="$pkgname-bash-completion:bashcomp:noarch $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/coccinelle/coccinelle/archive/$pkgver.tar.gz
	SCORE_expected.sexp
	"

prepare() {
	ln -sf ../../SCORE_expected.sexp tests/
}

build() {
	./autogen
	./configure \
		--prefix=/usr \
		--enable-release=yes \
		--with-python=/usr/bin/python3
	# Workaround: Build fails without forbidding parallel build
	make -j 1
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" MANDIR="/usr/share/man" install
}

bashcomp() {
	depends=""
	pkgdesc="Bash completions for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel bash-completion"

	amove usr/share/bash-completion/completions
}

sha512sums="496b1632c92cc026fbe28f784f56d4cd78f89a8ccd28dc7db1069c0c6b2b239675a10da305e37ed2a03c605668ecd3399aeed522f12ec3fbbf3ca07277ab7bce  coccinelle-1.0.8.tar.gz
5b5947b61eea90874f48bce06e045761d3b19af857541869a2a01818f4a41bc7181f78313170780e7f05ba88d2652c6b3caa427bd9f51ebb9267837090f7f7da  SCORE_expected.sexp"
